import 'package:auntserver/router_handler/routers.dart';
import 'package:fluro/fluro.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:provider/provider.dart';
import 'package:auntserver/model/beans.dart';
import 'package:auntserver/app_constants.dart';

import 'application.dart';
import 'model/entitys.dart';
void main(){
  FluroRouter router = FluroRouter();
  Routes.configureRoutes(router);
  AuntApp.router = router;
  setDesignWHD(375, 750);
  Provider.debugCheckInvalidValueType = null;
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider.value(value: new AuntEntity()),
        ChangeNotifierProvider.value(value: new ChooseIdentity(0,IdentityStatus.unselected)),
      ],
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primaryColor: AuntColors.AORANGE,
        accentColor: AuntColors.AORANGE,
        // Define the default font family.
        fontFamily: 'Montserrat',
        primaryTextTheme: TextTheme(bodyText1: TextStyle(color: AuntColors.ATEXT)),
        // Define the default TextTheme. Use this to specify the default
        // text styling for headlines, titles, bodies of text, and more.
        textTheme: TextTheme(
          subtitle1: TextStyle(fontSize: 20.0, fontWeight: FontWeight.normal),
          headline6: TextStyle(fontSize: 18.0, fontStyle: FontStyle.italic),
          bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
        ),
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
      builder: EasyLoading.init(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: GestureDetector(
        onTap: (){
          AuntApp.router.navigateTo(context, Routes.splash);
        },
        child: Center(
          child:Text(DateUtil.formatDateMs(DateUtil.getNowDateMs(),format: DateFormats.full)),
        ),
      ),
    );
  }

}
